//继承写法、权限(继承方式)、赋值、构造等

#include <iostream>
using namespace std;

class Student
{
public:
    Student(string name, int num, char sex)
        : _name(name), _num(num), _sex(sex) {}
    Student(Student &another) //拷贝构造器
    {
        this->_name = another._name;
        this->_num = another._num;
        this->_sex = another._sex;
    }

    void dis()
    {
        cout << "name:" << _name << endl;
        cout << "num :" << _num << endl;
        cout << "sex :" << _sex << endl;
    }

private:
    string _name;
    int _num;
    char _sex;
};


class Graduate:public Student
{
public:
    Graduate(string name, int num, char sex,double salary) //构造
        :Student(name,num,sex),_salary(salary) {}
    Graduate(Graduate &another) 
        :Student(another),_salary(another._salary) {}   //子类拷贝构造的格式 要求父类必须有拷贝构造
    void print()
    {
        dis();
        cout<<"salary:"<<_salary << endl;
    }
private:
    double _salary;
};


int main()
{
    Student s1("jmx",101,'m');  
    s1.dis();
    cout<<"==================="<<endl;
    Graduate g1("wei",102,'m',200000);
    g1.print();
    Graduate g2 = g1;
    g2.print();
    return 0;   
}